//
// Decompiled by Jadx - 348ms
//
package ea;

import androidx.constraintlayout.widget.i;
import ee.s;
import eg.b;
import ei.d;
import java.util.concurrent.atomic.AtomicReference;

public abstract class c<T> implements s<T>, b {
    public final AtomicReference<b> l = new AtomicReference<>();

    public final void dispose() {
        d.dispose(this.l);
    }

    public final boolean isDisposed() {
        return this.l.get() == d.DISPOSED;
    }

    public void k() {
    }

    public final void onSubscribe(b bVar) {
        boolean z;
        boolean z2;
        AtomicReference<b> atomicReference = this.l;
        Class<?> cls = getClass();
        if (bVar == null) {
            throw new NullPointerException("next is null");
        }
        while (true) {
            z = false;
            if (atomicReference.compareAndSet(null, bVar)) {
                z2 = true;
                break;
            } else if (atomicReference.get() != null) {
                z2 = false;
                break;
            }
        }
        if (!z2) {
            bVar.dispose();
            if (atomicReference.get() != d.DISPOSED) {
                i.dn(cls);
            }
        } else {
            z = true;
        }
        if (z) {
            k();
        }
    }
}
